/*=======================秒杀倒计时===================================*/

var oBox= document.getElementById('timer');
var end_time_str="2020/4/1 10:00:00";
CountDown()
function CountDown() {

    //获取当前时间
    var date = new Date();
    var now = date.getTime();
    //设置截止时间
    var endDate = new Date(end_time_str);

    var end = endDate.getTime();
    //时间差
    var leftTime = end-now;
    //定义变量 d,h,m,s保存倒计时的时间

    if (leftTime>0) {
        var hours = Math.floor(leftTime/1000/60/60%24);
        var minutes = Math.floor(leftTime/1000/60%60);
        var seconds = Math.floor(leftTime/1000%60);
    }else {
        var new_now_time = new Date()
        var year = new_now_time.getFullYear();
        var mouth = new_now_time.getMonth()+1;
        var day = new_now_time.getDate();

        new_now_time.setHours(new_now_time.getHours()+2)
        var hour = new_now_time.getHours();

        var minute = new_now_time.getMinutes();
        var secound = new_now_time.getSeconds();
        if (hour<9){
            end_time_str = year +"/" + mouth +"/" + day +" " +"0"+ hour +":"+minute+":"+secound
        }else {
            end_time_str = year +"/" + mouth +"/" + day +" " + hour +":"+minute+":"+secound
        }
        CountDown()
    }

    msg = "距离结束还有" + hours +"时" + minutes + "分" + seconds + "秒";
    oBox.innerHTML = msg;
    var start_str = new Date(end_time_str).getHours()-2
    if (new Date(end_time_str).getHours() == 0){
        document.querySelector(".start_time").innerHTML = 22+":00"
    }else{
        document.querySelector(".start_time").innerHTML = start_str+":00"
    }
    setInterval(CountDown, 1000);

}

/*=======================轮播上导航=======================================*/
$(function(){
    $(".mume-head .tab-head-item").mouseover(function(){
        var index=$(".mume-head .tab-head-item").index(this);
        $(".mume-head .xuanfu").eq(index).mouseover(function () {
            $(".mume-body .tab-body-item_a").eq(index).css("display","block")
        });
        $(".mume-head .xuanfu").eq(index).mouseout(function () {
            // console.log(index);
            $(".mume-body .tab-body-item_a").eq(index).mouseover(function () {
                $(".mume-body .tab-body-item_a").eq(index).css("display","block")
            })
            $(".mume-body .tab-body-item_a").eq(index).mouseout(function () {
                $(".mume-body .tab-body-item_a").eq(index).css("display","none")
            })
            $(".mume-body .tab-body-item_a").eq(index).css("display","none")
        });
    });
});
/*=======================果蔬鱼肉===================================*/
var tab_head1 = document.querySelector(".tab-head1");
var tab_head2 = document.querySelector(".tab-head2");
var tab_head3 = document.querySelector(".tab-head3");
var tab_head4 = document.querySelector(".tab-head4");
var tab_body1 = document.querySelector(".tab-body1");
var tab_body2 = document.querySelector(".tab-body2");
var tab_body3 = document.querySelector(".tab-body3");
var tab_body4 = document.querySelector(".tab-body4");

tab_head1.onclick = function () {
    tab_head1.style.borderBottomColor = "#11BCBC";
    tab_head2.style.borderBottomColor = "#fff";
    tab_head3.style.borderBottomColor = "#fff";
    tab_head4.style.borderBottomColor = "#fff";
    tab_body1.style.display = "block";
    tab_body2.style.display = "none";
    tab_body3.style.display = "none";
    tab_body4.style.display = "none";
}
tab_head2.onclick = function () {
    tab_head2.style.borderBottomColor = "#11BCBC";
    tab_head1.style.borderBottomColor = "#fff";
    tab_head3.style.borderBottomColor = "#fff";
    tab_head4.style.borderBottomColor = "#fff";
    tab_body2.style.display = "block";
    tab_body1.style.display = "none";
    tab_body3.style.display = "none";
    tab_body4.style.display = "none";
}
tab_head3.onclick = function () {
    tab_head3.style.borderBottomColor = "#11BCBC";
    tab_head1.style.borderBottomColor = "#fff";
    tab_head2.style.borderBottomColor = "#fff";
    tab_head4.style.borderBottomColor = "#fff";
    tab_body3.style.display = "block";
    tab_body2.style.display = "none";
    tab_body1.style.display = "none";
    tab_body4.style.display = "none";
}
tab_head4.onclick = function () {
    tab_head4.style.borderBottomColor = "#11BCBC";
    tab_head1.style.borderBottomColor = "#fff";
    tab_head2.style.borderBottomColor = "#fff";
    tab_head3.style.borderBottomColor = "#fff";
    tab_body4.style.display = "block";
    tab_body2.style.display = "none";
    tab_body1.style.display = "none";
    tab_body3.style.display = "none";
}
/*=======================搜索=======================================*/
$(".submitButton").click(function () {
    var key = $(".input-text").val();
    // var urlSrt = "${pageContext.request.contextPath}/product/"+key;
    console.log(key)
    // location.href = "/product?kw"+kw;
    location.href = "/fresh/product/comment?kw="+key;
    // document.querySelector(".input-text").value="";
})




